package com.zlk.algorithm.dataStructure.stack;

import java.util.Queue;
import java.util.Stack;

/**
 * @program: algorithm
 * @ClassName TwoStack2Queue
 * @description:两个栈实现队列
 * @author: slfang
 * @create: 2024-01-02 11:05
 * @Version 1.0
 **/
public class TwoStack2Queue {

    Stack<Integer> stackIn = new Stack<>();
    Stack<Integer> stackOut = new Stack<>();

    void push(int num){
        stackIn.push(num);
    }

    int poll(){
        if(stackOut.isEmpty()){
            while (!stackIn.isEmpty()){
                stackOut.add(stackIn.pop());
            }
        }
        return stackOut.pop();
    }


}
